package cn.piesat.client.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

@Component
public class SenderETTP {
    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    @Value("ETTP_TILED")
    private String fy4bGHITopic;


    public void FY4B(String file) {
        // /DATA/SWAP/FY4B/AGRI--/NatureColor_NoLit/FY4B-_GHI---_N_REGX_1330E_L1-_GEO-_MULT_NOM_20220618020900_20220618020959_2000M_V0001.HDF
        //                                0      1         2     3   4    5   6    7    8    9          10         11          12
        //fy4b-tc-20220618-0000.tif
        // 0    1   2       3
        String [] filePath = file.split("_");
        String template = "{\n" +
                "  \"dataTime\": \""+filePath[10]+"\",\n" +
                "  \"extent\": {\n" +
                "    \"bottomleftLat\": \"\",\n" +
                "    \"bottomleftLon\": \"\",\n" +
                "    \"bottomrightLat\": \"\",\n" +
                "    \"bottomrightLon\": \"\",\n" +
                "    \"topleftLat\": \"\",\n" +
                "    \"topleftLon\": \"\",\n" +
                "    \"toprightLat\": \"\",\n" +
                "    \"toprightLon\": \"\"\n" +
                "  },\n" +
                "  \"fileInfos\": [\n" +
                "    {\n" +
                "      \"dataLevel\": \"L1\",\n" +
                "      \"filePath\": \"/"+file.replace("/mnt/swap2_FY4B/DATA/SWAP/FY4B","")+"\",\n" +
                "      \"fileType\": \"tif\",\n" +
                "      \"productName\": \"真彩图无夜光\",\n" +
                "      \"productType\": \"NatureColor_NoLit\"\n" +
                "    },\n" +
                "  ],\n" +
                "  \"resolution\": \""+filePath[12].replace("M","")+"\",\n" +
                "  \"satellite\": \"FY4B\",\n" +
                "  \"sensor\": \""+filePath[2].replace("-","")+"\"\n" +
                "}";
        kafkaTemplate.send(fy4bGHITopic,template);

    }


    public void FY4B_GHI(String file) {
        String [] filePath = file.split("_");
        String template = "{\n" +
                "  \"dataTime\": \""+filePath[10]+"\",\n" +
                "  \"extent\": {\n" +
                "    \"bottomleftLat\": \"\",\n" +
                "    \"bottomleftLon\": \"\",\n" +
                "    \"bottomrightLat\": \"\",\n" +
                "    \"bottomrightLon\": \"\",\n" +
                "    \"topleftLat\": \"\",\n" +
                "    \"topleftLon\": \"\",\n" +
                "    \"toprightLat\": \"\",\n" +
                "    \"toprightLon\": \"\"\n" +
                "  },\n" +
                "  \"fileInfos\": [\n" +
                "    {\n" +
                "      \"dataLevel\": \"L1\",\n" +
                "      \"filePath\": \"/"+file.replace("/mnt/swap2_FY4B/DATA/SWAP/FY4B","")+"\",\n" +
                "      \"fileType\": \"tif\",\n" +
                "      \"productName\": \"真彩图无夜光\",\n" +
                "      \"productType\": \"GHINatureColor_NoLit\"\n" +
                "    },\n" +
                "  ],\n" +
                "  \"resolution\": \""+filePath[12].replace("M","")+"\",\n" +
                "  \"satellite\": \"FY4B\",\n" +
                "  \"sensor\": \""+filePath[2].replace("-","")+"\"\n" +
                "}";
        kafkaTemplate.send(fy4bGHITopic,template);

    }
    //三明治图
    public void FY4B_AGRI_SMZ(String file) {
        String [] filePath = file.split("_");
        String template = "{\n" +
                "  \"dataTime\": \""+filePath[11]+"\",\n" +
                "  \"extent\": {\n" +
                "    \"bottomleftLat\": \"\",\n" +
                "    \"bottomleftLon\": \"\",\n" +
                "    \"bottomrightLat\": \"\",\n" +
                "    \"bottomrightLon\": \"\",\n" +
                "    \"topleftLat\": \"\",\n" +
                "    \"topleftLon\": \"\",\n" +
                "    \"toprightLat\": \"\",\n" +
                "    \"toprightLon\": \"\"\n" +
                "  },\n" +
                "  \"fileInfos\": [\n" +
                "    {\n" +
                "      \"dataLevel\": \"L1\",\n" +
                "      \"filePath\": \"/"+file.replace("/mnt/swap2_FY4B/DATA/SWAP/FY4B","")+"\",\n" +
                "      \"fileType\": \"tif\",\n" +
                "      \"productName\": \"三明治云图\",\n" +
                "      \"productType\": \"SANDWICH\"\n" +
                "    },\n" +
                "  ],\n" +
                "  \"resolution\": \""+filePath[13].replace("M","")+"\",\n" +
                "  \"satellite\": \"FY4B\",\n" +
                "  \"sensor\": \""+filePath[2].replace("-","")+"\"\n" +
                "}";
        kafkaTemplate.send(fy4bGHITopic,template);

    }

}
